package com.ycsj.goldmedalnewconcept.teacher.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ycsj.goldmedalnewconcept.R;
import com.ycsj.goldmedalnewconcept.teacher.bean.StudentAnalyInfo;

import java.util.List;


/**
 * 学生分析适配器
 * Created by Administrator on 2018/7/2 0002.
 */

public class StudentAnalyRvAdapter extends BaseQuickAdapter<StudentAnalyInfo.DataBean, BaseViewHolder> {

    private Context context;
    private onDetailsClickListener listener;

    public StudentAnalyRvAdapter(Context context, int layoutResId, @Nullable List<StudentAnalyInfo.DataBean> data) {
        super(layoutResId, data);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, final StudentAnalyInfo.DataBean item) {

        //其它位置的文字标识
        TextView tvShowPos = helper.getView(R.id.tv_show_pos);
        tvShowPos.setText(helper.getLayoutPosition() + "");

        //姓名
        TextView tvName = helper.getView(R.id.tv_name);
        tvName.setText(item.getName());

        //出勤率
        TextView tvPresent = helper.getView(R.id.tv_present);
        tvPresent.setText(item.getPercent());

        //详情
        Button btDetails = helper.getView(R.id.bt_details);
        btDetails.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (listener != null) {
                    listener.onDetailsClick(item);
                }
            }
        });

    }

    public void setListener(onDetailsClickListener listener) {
        this.listener = listener;
    }

    public interface onDetailsClickListener {
        void onDetailsClick(StudentAnalyInfo.DataBean item);
    }
}
